﻿@using DualControl.CommonServices
@using DualControl.EmergencyMeasures.Dtos

@model Abp.Application.Services.Dto.ListResultDto<HSEmergencyMeasureListDto>
@using X.PagedList.Mvc.Core; @*import this so we get our HTML Helper*@
@using X.PagedList; @*import this so we can cast our list to IPagedList (only necessary because ViewBag is dynamic)*@

@inject ICommonService CommonService

@{
    ViewData["Title"] = "主要应急措施";
}

@section scripts
    {
    <environment names="Development">
        <script src="~/view-resources/Views/EmergencyMeasures/Index.js" asp-append-version="true"></script>
    </environment>
    <environment names="Staging,Production">
        <script src="~/view-resources/Views/EmergencyMeasures/Index.min.js" asp-append-version="true"></script>
    </environment>
}
<style>
    .table tbody tr th td {
        vertical-align: middle;
    }
</style>

<div class="row clearfix">
    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
        <div class="card">
            <div class="header">
                <h2>
                    @L("EmergencyMeasure")
                </h2>
                <ul class="header-dropdown m-r--5">
                    <li class="dropdown">
                        <a href="javascript:void(0);" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
                            <i class="material-icons">more_vert</i>
                        </a>
                        <ul class="dropdown-menu pull-right">
                            <li><a id="RefreshButton" href="javascript:void(0);" class="waves-effect waves-block"><i class="material-icons">refresh</i>@L("Refresh")</a></li>
                        </ul>
                    </li>
                </ul>
            </div>
            <div class="body table-responsive">



                @foreach (var hsemergencymeasure in ViewBag.PageOfHSEmergencyMeasureListDto)
                {

                    <div class="panel panel-primary">
                        <div class="panel-heading">
                            <h3 class="panel-title">
                                风险点编码：@hsemergencymeasure.Code &nbsp;风险点名称：@hsemergencymeasure.RiskPointName   车间/班组：&nbsp;@CommonService.GetOrganizationUnits().SingleOrDefault(c => c.Key == hsemergencymeasure.OrganizationUnitId).Value
                            </h3>
                        </div>
                        <div class="panel-body">
                            <h4 class="panel-title">危险源名称： @hsemergencymeasure.HazardSourceName   &nbsp;危险因素：@hsemergencymeasure.RiskFactor</h4>

                        </div>
                        <table class="table">
                            <thead>
                                <tr>
                                    <th width="10%">序号</th>
                                    <th width="50%">应急措施</th>

                                    <th width="30%">操作</th>
                                </tr>
                            </thead>

                            @{ if (hsemergencymeasure.EmergencyMeasures.Count > 0)
                                {


                                    int i = 0;

                                    @foreach (var controlmeasure in hsemergencymeasure.EmergencyMeasures)
                                    {

                                        i++;
                                        <tr>
                                            <td>@i.</td>
                                            <td>
                                                @controlmeasure.EmergencyMeasuresContent
                                            </td>
                                            <td>
                                                <span class="glyphicon glyphicon-pencil"></span>
                                                <button class="edit-controlmeasure" data-controlmeasure-id="@controlmeasure.Id" data-controlmeasure-controlcontent="@controlmeasure.EmergencyMeasuresContent" data-toggle="modal" data-target="#ControlMeasureEditModal">编辑</button>

                                                <span class="glyphicon glyphicon-remove"></span> <button class="delete-controlmeasure" data-controlmeasure-id="@controlmeasure.Id" data-hazardsource-name="">删除</button>
                                            </td>


                                        </tr>

                                    }
                                }

                            }
                            <tr>
                                <td>
                                    <button type="button" class="btn btn-primary btn-circle waves-effect waves-circle waves-float pull-left" data-toggle="modal" data-hazardsource-id="@hsemergencymeasure.Id" data-riskpoint-id="@hsemergencymeasure.RiskPointId" data-organizationunit-id="@hsemergencymeasure.OrganizationUnitId" data-target="#ControlMeasureCreateModal">
                                        <i class="material-icons">add</i>
                                    </button>
                                </td>
                            </tr>

                        </table>

                    </div>
                }
            </div>
        </div>
    </div>
</div>

@Html.PagedListPager((IPagedList)ViewBag.PageOfHSEmergencyMeasureListDto, page => Url.Action("Index", new { page }))

<div class="modal fade" id="ControlMeasureCreateModal" tabindex="-1" role="dialog" aria-labelledby="HazardSourceCreateModalLabel" data-backdrop="static">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title">
                    <span>主要应急措施</span>
                </h4>
            </div>
            <div class="modal-body">
                <form name="controlMeasureCreateForm" role="form" novalidate class="form-validation">
                    <input type="hidden" name="HazardSourceId" id="HazardSourceId" />
                    <input type="hidden" name="RiskPointId" id="RiskPointId" />
                    <input type="hidden" name="OrganizationUnitId" id="OrganizationUnitId" />

                    <div class="tab-content">
                        <div role="tabpanel" class="tab-pane animated fadeIn active" id="create-org-details">
                            <div class="row clearfix" style="margin-top:10px;">
                                <div class="col-sm-6">
                                    <div class="form-group form-float">
                                        <label class="form-label">管控措施1</label>
                                        <textarea class="form-control" id="controlmeasure1" type="text" name="controlmeasure1" required minlength="3" placeholder="请输入管控措施" autofocus></textarea>

                                    </div>
                                </div>
                                <div class="col-sm-6">
                                    <div class="form-group form-float">
                                        <label class="form-label">管控措施2</label>
                                        <textarea class="form-control" type="text" name="controlmeasure2" id="controlmeasure2" placeholder="请输入管控措施"></textarea>

                                    </div>
                                </div>

                            </div>

                            <div class="row clearfix" style="margin-top:10px;">
                                <div class="col-sm-6">
                                    <div class="form-group form-float">
                                        <label class="form-label">管控措施3</label>
                                        <textarea class="form-control" type="text" id="controlmeasure3" name="controlmeasure3" placeholder="请输入管控措施"></textarea>


                                    </div>
                                </div>

                                <div class="col-sm-6">
                                    <div class="form-group form-float">
                                        <label class="form-label">管控措施4</label>
                                        <textarea class="form-control" type="text" id="controlmeasure4" name="controlmeasure4" placeholder="请输入管控措施"></textarea>

                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default waves-effect" data-dismiss="modal">@L("Cancel")</button>
                        <button type="submit" class="btn btn-primary waves-effect">@L("Save")</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="ControlMeasureEditModal" tabindex="-1" role="dialog" aria-labelledby="HazardSourceEditModalLabel" data-backdrop="static">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title">
                    <span>编辑应急措施</span>
                </h4>
            </div>
            <div class="modal-body">
                <form name="hazardSourceEditForm" role="form" novalidate class="form-validation">
                    <input type="hidden" name="Id" id="Id" />               <div class="tab-content">
                        <div role="tabpanel" class="tab-pane animated fadeIn active" id="create-org-details">
                            <div class="row clearfix" style="margin-top:10px;">
                                <div class="col-sm-6">
                                    <div class="form-group form-float">
                                        <label class="form-label">管控措施</label>
                                        <input class="form-control" type="text" id="ControlContent" name="ControlContent" required minlength="3" placeholder="输入管控措施">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default waves-effect" data-dismiss="modal">@L("Cancel")</button>
                        <button type="submit" class="btn btn-primary waves-effect">@L("Save")</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
